<?php
/************************FoxPHP威客系统************************/
/*                                                            */
/*  FoxPHP.Com (C)2006-2016 FoxPHP Inc.                       */
/*  This is NOT a freeware, use is subject to license terms   */
/*  FoxPHP威客系统是商业软件,使用于商业用途请购买授权         */
/*  V3.0 2016.3                                               */
/*  foxphp@aliyun.com                                         */
/*  http://www.foxphp.com                                     */
/*                                                            */
/**************************************************************/

namespace Member\Controller;
use Think\Controller;
class MobileController extends IndexController {
	
	//1.发送手机验证码页面 
    public function indexAction(){
		$change=$_GET['change']==1 ? 1 : 0;
		if($change!=1){
			if(M('MemberCertificate')->where(" uid=$this->uid AND type=2 AND status=5 ")->count()){
				$this->redirect("/member/mobile/success",array());
			}
		}
		$this->assign('change',$change);
		$this->display();
    }
	
	//3.用户输入验证码 
	public function verifyAction(){
		
		$id=intval($_GET['id']);
		$memberverify=new \Register\Model\MemberVerifyModel();
		if(!$memberverify->IsMemberVerify(" id=$id AND status!=1 ")){
			$this->error('数据不存在!', '/member/mobile');
		}
		$this->assign('id',$id);
		$manage=$memberverify->IsMemberVerify(" id=$id ");
		$this->assign('manage',$manage);
		$verifyname=str_replace(substr($manage['mobile'],3,6),'******',$manage['mobile']);	 
		$this->assign('verifyname',$verifyname);
		$change=$_GET['change']==1 ? 1 : 0;
		$this->assign('change',$change);
		$this->display();	
    }
	
	//5.成功页面
	public function successAction(){
		
		$manage=M('MemberCertificate')->where(" uid=$this->uid AND type=2 AND status=5 ")->find();
		
		if($manage){
			$verifyname=str_replace(substr($manage['mobile'],3,6),'******',$manage['mobile']);	 
			$this->assign('verifyname',$verifyname);
		}else{
			$this->redirect("/member/mobile",array());
		}
		
		$this->display();
    }

}